<template>
  <div class="weight">
    <Form :model="editData" :rules="ruleValidate" ref="weight" :label-width="100">
      <Row :gutter="32" class="code-row-bg">
        <Col span="12">
          <Form-item prop="depth" :label="'深度权重'">
            <Input
              v-model.number="editData.depth"
            />
          </Form-item>
        </Col>
        <Col span="12">
          <Form-item prop="width" :label="'广度权重'">
            <Input
              v-model.number="editData.width"
            />
          </Form-item>
        </Col>
      </Row>
    </Form>
  </div>
</template>

<script>
export default {
  name: 'weightEdit',
  data() {
    return {
      editData: {
        depth: 10,
        width: 10
      },
      ruleValidate: {
        width: [
          { type: 'number', message:'请输入数字', trigger: 'blur' }
        ],
        depth: [
          { type: 'number', message:'请输入数字', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    actions() {
      return [
        {
          text: '取消',
          // icon: "edit",
          handle: () => this.$emit("Close"),
          loading: false
        },
        {
          text: '确认',
          theme: "primary",
          handle: () => {
            this.save('formValidate');
          },
        }
      ];
    },
  },
  methods: {
    save() {
      this.$refs['weight'].validate((valid) => {
        if (valid) {
          console.log("save", this.editData)
        } else {
          this.$Message.error('Fail!');
        }
      })
      
    }
  },
  created() {
    this.$emit("SetTitle", '权重配置');
    this.$emit("SetPageMinHeight", 0);
    this.$emit("SetPageWidth", 500);
    this.$emit("SetPageActions", this.actions);
  }
}
</script>

<style lang="less" scoped>
</style>